package enums.table;

import java.util.ArrayList;
import java.util.List;

/**
 * 数据库类型枚举
 */
public enum InitImportEnum {
	BigDecimal ("java.math.BigDecimal", ""),
	Date ("java.util.Date",  "日期"),
	List ("java.util.List",  "List集合"),
	Page ("entity.Page",  "分页类"),
	PageResult ("entity.result.PageResult",  "分页类"),
	Logger ("org.slf4j.Logger",  "日志"),
	LoggerFactory ("org.slf4j.LoggerFactory",  "日志"),

	FeignClient ("org.springframework.cloud.openfeign.FeignClient",  ""),
	GetMapping ("org.springframework.web.bind.annotation.GetMapping",  ""),
	PostMapping ("org.springframework.web.bind.annotation.PostMapping",  ""),
	RequestBody ("org.springframework.web.bind.annotation.RequestBody",  ""),

	Autowired ("org.springframework.beans.factory.annotation.Autowired",  ""),
	RequestMapping ("org.springframework.web.bind.annotation.RequestMapping",  ""),
	RequestParam ("org.springframework.web.bind.annotation.RequestParam",  ""),
	RestController ("org.springframework.web.bind.annotation.RestController",  ""),
	Component ("org.springframework.stereotype.Component",  ""),

	StrUtil ("utils.common.StrUtil",  ""),
	;

	// 类名
	private String clazzImport;
	// 备注
	private String remark;

	public static void main(String args[]) {
		/*for (InitImportEnum tableType : InitImportEnum.values()) {
			System.out.println(tableType.toString().toUpperCase()
					+ " " + "(\"" + tableType.getDataType().toLowerCase() + "\","
					+ " " + "\"" + tableType.getJavaType() + "\","
					+ " " + "\"" + tableType.getRemark() + "\"),"
					);
		}*/
	}

	private InitImportEnum(String clazzImport, String remark) {
		this.clazzImport = clazzImport;
		this.remark = remark;
	}

	public String getClazzImport() {
		return clazzImport;
	}

	public void setClazzImport(String clazzImport) {
		this.clazzImport = clazzImport;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	/**
	 * 获取数据库类型枚举 List集合
	 */
	public static List<InitImportEnum> enumList() {
		List<InitImportEnum> list = new ArrayList<>();
		for (InitImportEnum tableType : InitImportEnum.values()) {
			list.add(tableType);
		}
		return list;
	}

	/**
	 * 根据 数据库字段类型 获取 Java类型
	 */
	public static InitImportEnum getEnumByDataType(String clazzImport) {
		if (null == clazzImport) {
			return null;
		}
		for (InitImportEnum tableType : InitImportEnum.values()) {
			if (tableType.getClazzImport().equals(clazzImport)) {
				return tableType;
			}
		}
		return null;
	}

	/**
	 * 获取初始化时数据
	 */
	public static List<String> initEntityList() {
		List<String> list = new ArrayList<>();
		list.add(List.getClazzImport());
		list.add(Date.getClazzImport());
		return list;
	}
}
